package com.gangquan360.smartadmin.module.supplier.controller;

import com.gangquan360.smartadmin.common.domain.PageResultDTO;
import com.gangquan360.smartadmin.common.domain.ResponseDTO;
import com.gangquan360.smartadmin.constant.SwaggerTagConst;
import com.gangquan360.smartadmin.module.supplier.domain.dto.SupplierDTO;
import com.gangquan360.smartadmin.module.supplier.domain.dto.SupplierQueryDTO;
import com.gangquan360.smartadmin.module.supplier.service.SupplierService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

/**
 * [ 供应商表 ]
 *
 * @author wiggin
 * @version 1.0
 * @company wiggin
 * @copyright (c) 2019 wigginInc. All rights reserved.
 * @date 2020-03-14 13:48:57
 * @since JDK1.8
 */
@RestController
@Api(tags = {SwaggerTagConst.Group2.SUPPLIER_MANGER})
public class SupplierController {

    @Autowired
    private SupplierService supplierService;

    @ApiOperation(value = "分页查询供应商表",notes = "@author wiggin")
    @PostMapping("/supplier/page/query")
    public ResponseDTO<PageResultDTO<SupplierDTO>> queryByPage(@RequestBody SupplierQueryDTO queryDTO) {
        return supplierService.queryByPage(queryDTO);
    }

    @ApiOperation(value = "添加供应商表",notes = "@author wiggin")
    @PostMapping("/supplier/add")
    public ResponseDTO<String> add(@RequestBody @Valid SupplierDTO addTO){
        return supplierService.add(addTO);
    }

    @ApiOperation(value="修改供应商表",notes = "@author wiggin")
    @PostMapping("/supplier/update")
    public ResponseDTO<String> update(@RequestBody @Valid SupplierDTO updateDTO){
        return supplierService.update(updateDTO);
    }


    @ApiOperation(value="删除供应商表",notes = "@author wiggin")
    @GetMapping("/supplier/delete/{id}")
    public ResponseDTO<String> delete(@PathVariable("id") Long id){
        return supplierService.delete(id);
    }


    @ApiOperation(value="详情供应商表",notes = "@author wiggin")
    @GetMapping("/supplier/detail/{id}")
    public ResponseDTO<SupplierDTO> detail(@PathVariable("id") Long id){
        return supplierService.detail(id);
    }
}
